package com.xunwulian.base.dao;

import com.xunwulian.base.entity.CardNodeEntity;
import com.xunwulian.base.entity.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

@Mapper
public interface CardNodeDao {

    int insertBatch(LinkedList<CardNodeEntity> list);

    int insert(CardNodeEntity entity);

    List<CardNodeEntity> getByUserId(@Param("userId") String userId);

    CardNodeEntity getById(@Param("id") Long id);

    List<CardNodeEntity> listAll();

    int isExists(@Param("cardNodeId") String cardNodeId);

    /***
     * 分页列表
     *
     */
    List<CardNodeEntity> listPage(@Param("page") Page page,
                                  @Param("appId") String appId,
                                  @Param("userId") String userId,
                                  @Param("msisdnKey") String msisdnKey,
                                  @Param("userNameKey") String userNameKey);

    // 更新号段的用户ID或者用户激活日期
    void updateUserIdOrOpenDate(@Param("authUserId") String authUserId,
                                @Param("authUserName") String authUserName,
                                @Param("openDate") Date openDate,
                                @Param("userOpenDate") Date userOpenDate,
                                @Param("id") Integer id,
                                @Param("appId") String appId,
                                @Param("pkg") Integer pkg,
                                @Param("userPkg") Integer userPkg,
                                @Param("userPrice") Double userPrice);

    void update(@Param("id") long id,
                @Param("cardNodeId") String cardNodeId,
                @Param("openDate") Date openDate,
                @Param("userOpenDate") Date userOpenDate,
                @Param("appId") String appId,
                @Param("pkg") Integer pkg,
                @Param("userPkg") Integer userPkg,
                @Param("userPrice") Double userPrice);

    void updateRange(@Param("start") Long start,
                     @Param("end") Long end,
                     @Param("id") Integer id,
                     @Param("openDate") Date openDate,
                     @Param("userOpenDate") Date userOpenDate,
                     @Param("userId") String userId,
                     @Param("userName") String userName,
                     @Param("appId") String appId,
                     @Param("pkg") Integer pkg,
                     @Param("userPkg") Integer userPkg,
                     @Param("userPrice") Double userPrice);

    void delete(@Param("id") Integer id);

    void deleteAll();

}
